﻿using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Office.OneNote.Interop;

namespace Microsoft.Office.OneNote
{
    [DebuggerDisplay("SectionGroup {Name}")]
    [OneNoteXmlElementAttribute("SectionGroup")]
    [OneNoteHierarchyType(CreateHierarchyType.SectionGroup)]
    [SuppressMessage("Microsoft.Maintainability", "CA1501:AvoidExcessiveInheritance")]
    public sealed class OneNoteSectionGroup : OneNoteSectionBase
    {
        [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
        internal OneNoteSectionGroup(OneNoteObjectId id)
            : base(id)
        {
        }

        public override OneNoteColor Color
        {
            get { return OneNoteColor.None; }
            set { }
        }

        public OneNoteSection OpenSection(string name)
        {
            return OpenSection(name, false);
        }

        public OneNoteSection OpenSection(string name, bool openExisting)
        {
            Contract.RequiresValidFileName(name, "name");

            return OneNoteSection.Open(name, this, openExisting);
        }

        public OneNoteSectionGroup OpenSectionGroup(string name)
        {
            return OpenSectionGroup(name, false);
        }

        public OneNoteSectionGroup OpenSectionGroup(string name, bool openExisting)
        {
            Contract.RequiresValidFileName(name, "name");

            return Storage.Open<OneNoteSectionGroup>(name, ObjectId, openExisting);
        }
    }
}
